﻿<Page x:Class="App4.MainPage"
      xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
      xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
      xmlns:Behaviors="using:App4.Behaviors"
      xmlns:Core="using:Microsoft.Xaml.Interactions.Core"
      xmlns:Interactivity="using:Microsoft.Xaml.Interactivity"
      xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
      xmlns:local="using:App4"
      xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
      d:DataContext="{d:DesignInstance Type=local:MainPage}"
      mc:Ignorable="d">

    <Grid x:Name="grid" Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
        <StackPanel HorizontalAlignment="Center" VerticalAlignment="Center">
            <TextBlock Margin="0,10"
                       Style="{StaticResource HeaderTextBlockStyle}"
                       Text="Tri-State" />
            <StackPanel Orientation="Horizontal">
                <Button Click="TrueButton_Click" Content="True" />
                <Button Click="FalseButton_Click" Content="False" />
                <Button Click="NullButton_Click" Content="Null" />
            </StackPanel>
            <TextBlock Margin="0,10" Text="{Binding State, TargetNullValue=Null}" />

            <!--  standard  -->
            <CheckBox Margin="0,10"
                      Content="Standard Checkbox"
                      IsChecked="{Binding State, Mode=TwoWay}"
                      IsThreeState="True" />

            <!--  attached prop  -->
            <CheckBox Margin="0,10"
                      Content="Attached Property"
                      IsThreeState="True"
                      local:NullableCheckboxProperty.Enabled="true"
                      local:NullableCheckboxProperty.IsChecked="{Binding State, Mode=TwoWay}" />

            <!--  behavior  -->
            <CheckBox Margin="0,10"
                      Content="Blend Behavior"
                      IsThreeState="True">
                <Interactivity:Interaction.Behaviors>
                    <Behaviors:NullableCheckboxBehavior IsChecked="{Binding State, Mode=TwoWay}" />
                </Interactivity:Interaction.Behaviors>
            </CheckBox>

            <!--  subclass  -->
            <Controls:NullableCheckbox xmlns:Controls="using:App4.Controls"
                                       Margin="0,10"
                                       Content="Custom control"
                                       IsChecked2="{Binding State, Mode=TwoWay}"
                                       IsThreeState="True" />
        </StackPanel>
    </Grid>
</Page>
